'use strict'

class delarticle{
    constructor(){
        this.param = '/'
    }

    async post(c){
        let a = c.service.fun;
        let {user_id,article_id} = JSON.parse(c.body)
        c.setHeader('content-type', 'text/html; charset=utf-8')
        let data1 = await a.sel('article_list',{'article_id':`${article_id}`},['poster_id'],c.service.pool)
        let {poster_id} = data1.rows[0]
        if(user_id == poster_id){
            a.del('like_list',{'liked_article_id':`${article_id}`},c.service.pool)
            a.del('comment_list',{'comment_article_id':`${article_id}`},c.service.pool)
            a.del('article_list',{'article_id':`${article_id}`,'poster_id':`${user_id}`},c.service.pool)
            c.send('success')
        }else{
            c.send('fail')
        }
        
    }
}


module.exports = delarticle